import sun.tools.jar.resources.jar_fr;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by user on 09.02.14.
 */
public class MainFrame extends JFrame {
    private JTextField textField;
    private UIManager UI;
    public MainFrame() {
        JFrame jFrame = new JFrame("My Float Frame");
        jFrame.setSize(400,200);
        jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        UI=new UIManager();
        UI.put("OptionPane.background", Color.white);
        UI.put("Panel.background", Color.white);



        JPanel panel = new JPanel(new BorderLayout());
        JLabel text = new JLabel("Text");
        textField = new JTextField();
        text.setLabelFor(textField);
        panel.add(text, BorderLayout.WEST);
        panel.add(textField,BorderLayout.CENTER);
        jFrame.add(panel,BorderLayout.NORTH);

        JPanel panel2 = new JPanel(new BorderLayout());
        Box boxRadio = Box.createVerticalBox();
        ButtonGroup group = new ButtonGroup();
        JRadioButton red =new JRadioButton("red");
        red.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                UI.put("OptionPane.messageForeground", Color.red);
            }
        });
        JRadioButton green =new JRadioButton("green");
        green.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                UI.put("OptionPane.messageForeground", Color.green);
            }
        });
        JRadioButton blue =new JRadioButton("blue");
        blue.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                UI.put("OptionPane.messageForeground", Color.blue);
            }
        });
        group.add(red);
        group.add(green);
        group.add(blue);
        boxRadio.add(red,BorderLayout.NORTH);
        boxRadio.add(green,BorderLayout.CENTER);
        boxRadio.add(blue,BorderLayout.SOUTH);

        jFrame.add(boxRadio,BorderLayout.CENTER);

        JButton show = new JButton("SHOW");
        show.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(null, textField.getText(), "Mess", JOptionPane.INFORMATION_MESSAGE, null);
            }
        });
        JPanel panelShow = new JPanel();
        panelShow.add(show,BorderLayout.CENTER);
        jFrame.add(panelShow,BorderLayout.SOUTH);


        jFrame.setVisible(true);
    }
}
